package com.sinux.generality.basesupport.utils.kafka.producer;

import java.util.List;
import java.util.Map;

public class ProducerFactory {

    public static final String buildName_default = "default";
    public static final String buildName_simple = "simple";

    public static KafkaProducerInterface buildProducerClassByBoostrapServers(String buildName, List<String> boostrapServers) {
        KafkaProducerInterface result = null;
        if(buildName_default.equals(buildName)){
            return new DefaultKafkaProducerClass(boostrapServers);
        }
        else if(buildName_simple.equals(buildName)){
            return new SimpleKafkaProducerClass(boostrapServers);
        }
        return result;
    }

    public static KafkaProducerInterface buildProducerClassByConfigMap(String buildName, Map<String,Object> configMap) {
        KafkaProducerInterface result = null;
        if(buildName_default.equals(buildName)){
            return new DefaultKafkaProducerClass(configMap);
        }
        else if(buildName_simple.equals(buildName)){
            return new SimpleKafkaProducerClass(configMap);
        }
        return result;
    }

    public static KafkaProducerInterface buildProducerClassByObject(String buildName,Object o) {
        KafkaProducerInterface result = null;
        if(buildName_default.equals(buildName)){
            return new DefaultKafkaProducerClass((DefaultKafkaProducerClass) o);
        }
        else if(buildName_simple.equals(buildName)){
            return new SimpleKafkaProducerClass((SimpleKafkaProducerClass) o);
        }
        return result;
    }
}

